#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define FILE(x) freopen(x".in","r",stdin);\
	freopen(x".out","w",stdout);
#define pb push_back

int read(){
	int x = 0,sgn = 1;char ch = getchar();
	for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;
	for(;isdigit(ch);ch = getchar()) x = (x<<1)+(x<<3)+(ch^48);
	return x*sgn;
}

const int N = 1e4+10;

int dep[N],fa[N],add[N],to[N],n,m,vv[N],u[N];
bool vis[N],v[N<<1],intree[N<<1];
vector<int> ans,must;
vector<pii> G[N];

void check(int x,int y,int num){
	if((dep[x] - dep[y]) & 1) add[y]++, add[x]--;
	else must.pb(num),add[x]++,add[y]--;
}

void dfs(int x){
	vis[x] = 1;
	for(pii d : G[x]){
		int y = d.fi,num = d.se;
		if(v[num]) continue; v[num] = 1;
		if(vis[y]) check(x,y,num);
		else dep[y] = dep[x] + 1,fa[y] = x,intree[num] = 1,to[y] = num,dfs(y);
	}
}

void up(int x){
	for(pii d : G[x]){int y = d.fi; if(y == fa[x] || !intree[d.se]) continue; up(y); add[x] += add[y];}
}

void get(int x,int y){
	if(dep[x] < dep[y]) swap(x,y);
	while(x ^ y){
		if(add[x] == must.size()) ans.pb(to[x]);
		x = fa[x];
	}
}

int main (){
#ifndef ONLINE_JUDGE
	freopen("1.in","r",stdin);
#endif
	n = in,m = in;
	for(int i = 1;i <= m;i++){
		u[i] = in,vv[i] = in;
		G[u[i]].pb(pii(vv[i],i)); G[vv[i]].pb(pii(u[i],i));
	}
	for(int i = 1;i <= n;i++) if(!vis[i]) dfs(i);
	for(int i = 1;i <= n;i++) if(!fa[i]) up(i);
	if(!must.size()) {printf("%d\n",m); for(int i = 1;i <= m;i++) printf("%d%c",i," \n"[i==m]);return 0;}
	else if(must.size() == 1){ans.pb(must.back());get(u[must.back()],vv[must.back()]);}
	else{for(int t : must) {get(u[t],vv[t]);break;}}
	printf("%lu\n",ans.size()); sort(ans.begin(),ans.end());
	for(int t : ans) printf("%d%c",t," \n"[t==ans.back()]);
	return 0;
}

